﻿using SQLite.CodeFirst;
using System.Data.Entity;
namespace Lesson1
{
    public class MyContext:DbContext
    {
        //指定自定义的数据库连接 MyConnection
        public MyContext() : base("MyConnection") { }
        //重写如下方法，否则默认用的是SqlServer 的模型创建方法 
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            var init = new SqliteCreateDatabaseIfNotExists<MyContext>(modelBuilder);
            Database.SetInitializer(init);
        }
        public DbSet<Student> Students { get; set; }
    }
}
